package statistic;

import common.db.DBExecute;
import common.main.MainBean;

public class ClientCountBean extends MainBean
{
	public void funcExecute() throws Exception
	{
		String from = (String)inputTable.get("from");
		String to = (String)inputTable.get("to");
		
		queryBuffer = new StringBuffer();
		
		queryBuffer.append("SELECT b.TOTAL_COUNT, d.ID_COUNT, b.TIME FROM ( SELECT COUNT(TIME) TOTAL_COUNT, TIME ");
		queryBuffer.append("FROM ( SELECT SEQ, TO_CHAR(TIME, 'YYYY-MM-DD')  TIME ");
		queryBuffer.append("FROM CLIENT_COUNT WHERE TO_CHAR(TIME, 'YYYY-MM-DD')>= '"+from+"' ");
		queryBuffer.append("AND TO_CHAR(TIME, 'YYYY-MM-DD')<='"+to+"' ) a GROUP BY TIME ORDER BY TIME ) b, ( ");
		queryBuffer.append("SELECT COUNT(c.C_ID) ID_COUNT, c.TIME FROM ( SELECT DISTINCT ID C_ID, TO_CHAR(TIME, 'YYYY-MM-DD') TIME ");
		queryBuffer.append("FROM CLIENT_COUNT ) c GROUP BY c.TIME ) d WHERE b.TIME = d.TIME");
		
		DBExecute dbe = new DBExecute(queryBuffer.toString());
		
		outputList = dbe.getDataList();
	}
}
